<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>返现登记管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" />
	<style type="text/css">
		.layui-table tbody .layui-table-cell {
			height: auto;
			line-height: 88px;
		}
	</style>
</head>
<body class="childrenBody">
	<blockquote class="layui-elem-quote quoteBox">
		<form class="layui-form" method="post" action="/register/export">
			<input type="hidden" name="formId" value="${formId}" />
			<div class="layui-inline">
				<label class="layui-input-inline">客服名：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="customName" id="customName" placeholder="请输入客服名" />
				</div>
				<label class="layui-input-inline">旺旺号：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="wangWang" id="wangWang" placeholder="请输入旺旺号" />
				</div>

				<label class="layui-input-inline">订单编号：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="orderNum" id="orderNum" placeholder="请输入订单编号" />
				</div>
				<label class="layui-input-inline">微信号：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="weChat" id="weChat" placeholder="请输入微信号" />
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-input-inline">月份：</label>
				<div class="layui-input-inline">
					<select class="form-control"id="month">
						<option value="">全部</option>
					<option value="一月">一月</option>
					<option value="二月" >二月</option>
					<option value="三月" >三月</option>
					<option value="四月" >四月</option>
					<option value="五月" >五月</option>
					<option value="六月">六月</option>
					<option value="七月" >七月</option>
					<option value="八月">八月</option>
					<option value="九月">九月</option>
					<option value="十月">十月</option>
					<option value="十一月">十一月</option>
					<option value="十二月">十二月</option>
					</select>
				</div>
				<label class="layui-input-inline">是否返款：</label>
				<div class="layui-input-inline">
					<select class="form-control"id="backMoney">
						<option value="">全部</option>
						<option value="是">是</option>
						<option value="否" >否</option>
					</select>
				</div>
				<label class="layui-input-inline">开始时间：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="startDate" id="startDate" placeholder="请输入开始时间" />
				</div>
				<label class="layui-input-inline">结束时间：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="endDate" id="endDate" placeholder="请输入结束时间" />
				</div>
				<label class="layui-input-inline">店铺：</label>
				<div class="layui-input-inline">
					<select class="form-control"id="storeId">
						<option value="">全部</option>
						<#list storeList as store>
							<option value="${store.id}">${store.name}</option>
						</#list>
					</select>
				</div>
				<label class="layui-input-inline">进店关键词：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="keyWord" id="keyWord" placeholder="请输入进店关键词" />
				</div>
				<label class="layui-input-inline">进店连接：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="url" id="url" placeholder="请输入进店连接" />
				</div>
				<a class="layui-btn search_btn" data-type="reload">搜索</a>
				<a class="layui-btn layui-btn-normal add_btn">添加</a>
				<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="exportBtn"  type="submit" >导出</button>
			</div>
		</form>
	</blockquote>
	<table id="entityList" lay-filter="entityList"></table>



<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">
    layui.use(['form','layer','laydate','table','laytpl', 'baseutil', 'dialog'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            dialog = layui.dialog,
            baseutil = layui.baseutil,
            laytpl = layui.laytpl,
            table = layui.table;
        laydate.render({
            elem: '#startDate', //指定元素
            type: 'datetime'
        });
        laydate.render({
            elem: '#endDate', //指定元素
            type: 'datetime'
        });
        //指定允许上传的文件类型
        baseutil.importExecl('#import',"/register/import",function (data) {

        })
        //列表
        var tableIns = table.render({
            elem: '#entityList',
            url : '/register/jsonList',
            cellMinWidth : 95,
            page : true,
            height : "full-125",
            limit : 20,
            method:'post',
            limits : [10,15,20,25],
            id : "entityList",
            cols : [[
                {type: 'numbers', title: '序号'},
                {field: 'id', title: 'id号',align:'center',width:100},
                {field: 'customName', title: '客服名',align:'center',width:100},
                {field: 'wangWang', title: '旺旺号',align:'center',width:110},
                {field: 'orderNum', title: '订单编号',align:'center',width:120},
                {field: 'weChat', title: '微信号',align:'center',width:160},
                {field: 'keyWord', title: '进店关键词',align:'center',width:120},
                {field: 'url', title: '进店链接',align:'center',width:120},
                {field: 'ewm', title: '微信收款码',align:'center', templet:function(d){
                	if(d.ewm!=null&&d.ewm!=""){
                        return "<img src='"+d.ewm+"'  lay-event='show' style='width: 60px;height:80px;'/>";
					}else{
                        return "无";
					}
                },width:140},
                {field: 'backMoney', title: '是否返款',align:'center'},
                {field: 'money', title: '返款总金额',align:'center',width:120},
                {field: 'returnTime', title: '返款日期',align:'center',width:160, templet:function(d){
                    if(d.returnTime==null||d.returnTime==""){
                        return "";
                    }else{
                        return timeStamp2String(d.returnTime);
                    }
                }},
                {field: 'returnBank', title: '返款银行',align:'center'},
                {field: 'remark', title: '备注',align:'center'},
                {field: 'gift', title: '礼品',align:'center',width:120},
                {field: 'storeName', title: '店铺名称',align:'center'},
                {field: 'month', title: '月份',align:'center'},
                {field: 'createTime', title: '创建时间',align:'center',width:160, templet:function(d){
                    return timeStamp2String(d.createTime);
                }},
                {field: 'updateTime', title: '修改时间',align:'center',width:160, templet:function(d){
                    return timeStamp2String(d.updateTime);
                }},
                {title: '操作',width:160,align:"center",fixed: 'right', templet:function(d){
                    return '<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>\
                    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>';
                }}
            ]]
        });

        //搜索
        $(".search_btn").on("click",function(){
            table.reload("entityList",{
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    customName: $("#customName").val(),
                    wangWang: $("#wangWang").val(),
                    storeId: $("#storeId").val(),
                    orderNum: $("#orderNum").val(),
                    weChat: $("#weChat").val(),
                    startDate: $("#startDate").val(),
                    endDate: $("#endDate").val(),
                    backMoney: $("#backMoney").val(),
                    month: $("#month").val(),
                    url: $("#url").val(),
                    keyWord: $("#keyWord").val()

                }
            })
        });
        //增加/编辑
        function addEntity(params){
            var title="修改";
            if(params==null||params==""){
                title="添加"
            }
            var index = layui.layer.open({
                title :title,
                type : 2,
                content : "/register/selectEntity"+params,
                success : function(layero, index){
                    var body = layui.layer.getChildFrame('body', index);
                    body.find(".closeLay").bind("click",function () {
                        layui.layer.close(index);
                    })
                    layui.layer.full(index);
                }
            });
        }
        $(".add_btn").click(function(){
            addEntity('');
        })

        //列表操作
        table.on('tool(entityList)', function(obj){
            var layEvent = obj.event,
                data = obj.data;
            if(layEvent === 'edit'){ //编辑
                addEntity("?id="+data.id);
            }else if(layEvent === 'show'){ //展示
                dialog.imageSingleShow(data.ewm);
            }else if(layEvent === 'del'){ //删除
                layer.confirm('是否删除订单编号【'+data.orderNum+'】吗？',{icon:3, title:'提示信息'},function(index){
                    $.get("/register/deleteEntity",{
                        "id":data.id,
                        "_method":"DELETE"
                    },function(result){
                        if(1==result.returnInfo.state){
                            tableIns.reload();
                            layer.close(index);
                        }else{
                            top.layer.msg(result.returnInfo.errorMsg);
                        }
                    })
                });
            }
        });

    })
    function timeStamp2String(time){
        var datetime = new Date();
        datetime.setTime(time);
        var year = datetime.getFullYear();
        var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
        var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
        var hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours();
        var minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
        var second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
        return year + "-" + month + "-" + date+" "+hour+":"+minute+":"+second;
    }
</script>
</body>
</html>